home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / AppsToGo / AppsToGo.src / DTS.Draw / TExtSelectObj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-18  |  2.9 KB  |  135 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        TExtSelectObj.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* See the files "=How to write your app" and "=Using TreeObj.c" for information
  20. ** on this function. */
  21.  
  22. /* This file implements the messages for the round-rect object.  Many of the messages
  23. ** can be handled by the rect object, as they deal with a rect structure.  Only
  24. ** a few of them are round-rect-specific. */
  25.  
  26. /* It would seem that you would want a custom hit-test message handler here, but
  27. ** the rect object first checks to see if the hit is within the bounding box of
  28. ** the object, and if so, it then calls the object to return the region.  This
  29. ** allows the rect object to generically handle hit-testing. */
  30.  
  31.  
  32.  
  33. /*****************************************************************************/
  34.  
  35.  
  36.  
  37. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  38. #include "App.protos.h"        /* Get the prototypes for the application.        */
  39.  
  40. #ifndef __OSEVENTS__
  41. #include <OSEvents.h>
  42. #endif
  43.  
  44. #ifndef __OSUTILS__
  45. #include <OSUtils.h>
  46. #endif
  47.  
  48. #ifndef __QUICKDRAW__
  49. #include <Quickdraw.h>
  50. #endif
  51.  
  52. #ifndef __STRING__
  53. #include <String.h>
  54. #endif
  55.  
  56. #ifndef __TREEOBJ2__
  57. #include "TreeObj2.h"
  58. #endif
  59.  
  60. #ifndef __UTILITIES__
  61. #include "Utilities.h"
  62. #endif
  63.  
  64.  
  65.  
  66. #pragma segment DrawObjects
  67. long    TExtSelectObj(TreeObjHndl hndl, short message, long data)
  68. {
  69.     Rect        rct;
  70.     RgnHandle    rgn;
  71.  
  72.     switch (message) {
  73.         case FREEMESSAGE:
  74.         case COPYMESSAGE:
  75.         case UNDOMESSAGE:
  76.         case CONVERTMESSAGE:
  77.         case FREADMESSAGE:
  78.         case FWRITEMESSAGE:
  79.         case HREADMESSAGE:
  80.         case HWRITEMESSAGE:
  81.         case HITTESTMESSAGE:
  82.         case GETOBJRECTMESSAGE:
  83.         case SETOBJRECTMESSAGE:
  84.         case SECTOBJRECTMESSAGE:
  85.         case GETBBOXMESSAGE:
  86.         case CLICKMESSAGE:
  87.         case KEYMESSAGE:
  88.         case SETSELECTMESSAGE:
  89.         case GETSELECTMESSAGE:
  90.         case SIZEMESSAGE:
  91.         case COMPAREMESSAGE:
  92.             return(TRectObj(hndl, message, data));
  93.             break;
  94.  
  95.         case INITMESSAGE:
  96.             break;
  97.  
  98.         case GETRGNMESSAGE:
  99.             rgn = NewRgn();
  100.             rct = mDerefCommon(hndl)->rect;
  101.             RectRgn(rgn, &rct);
  102.             return((long)rgn);
  103.             break;
  104.  
  105.         case DRAWMESSAGE:
  106.             rct = mDerefRRect(hndl)->rect;
  107.             switch (data) {
  108.                 case DRAWOBJ:
  109.                     PenMode(patXor);
  110.                     PenPat((ConstPatternParam)&qd.gray);
  111.                     FrameRect(&rct);
  112.                     PenNormal();
  113.                     break;
  114.                 case ERASEOBJ:
  115.                     EraseRect(&rct);
  116.                     break;
  117.             }
  118.             break;
  119.  
  120.         case PRINTMESSAGE:
  121.             break;
  122.  
  123.         case VHMESSAGE:
  124.             break;
  125.  
  126.         default:
  127.             break;
  128.     }
  129.  
  130.     return(noErr);
  131. }
  132.  
  133.  
  134.  
  135.